#ifndef KRAW3DINPUT_H
#define KRAW3DINPUT_H

#include "kraw/krawdefs.h"

#include "kernel/ntypes.h"
#include "mathlib/vector.h"
#include "util/nhashmap.h"

//-----------------------------------------------------------------------------

enum EMouseButton
{
    Button_Left = 0,
    Button_Right,
    Button_Center,
    Num_MouseButtons
};

enum EInputEvent
{
    Event_Key = 0,
    Event_Button,
    Event_Mouse,
};

enum EMouseEvent
{
    Mouse_Up,
    Mouse_Down,
    Mouse_Left,
    Mouse_Right,
    Num_MouseEvents
};

struct InputEvent;

class Kraw3DInput
{
public:

//    static Kraw3DInput* Create( const char* name );

    static void OnKey( const uint key, const bool pressed );
    static void OnMouseMove( const int x, const int y );
    static void OnMouseButton( const int x, const int y, const EMouseButton button, const bool pressed );

    virtual void Tick( float fElapsedTime );

    //configure input mapping
    void KeyEvent( const char*, uint, bool );
    void ButtonEvent( const char*, EMouseButton, bool );
    void MouseEvent( const char*, EMouseEvent );

    bool GetState( const char* );
    float GetValue( const char* );

protected:

    nArray<InputEvent> inputEvents;
    nHashMap eventMap;

    static void SetKey( uint key, bool pressed );
    static bool GetKey( uint key );

    static ushort keys[256];
    static float mouse[Num_MouseEvents];
    static bool buttons[Num_MouseButtons];
};

#endif /*KRAW3DINPUT_H*/
